home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / xpcom / nsIAsyncInputStream.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  10KB  |  255 lines

  1. /*
  2.  * DO NOT EDIT.  THIS FILE IS GENERATED FROM nsIAsyncInputStream.idl
  3.  */
  4.  
  5. #ifndef __gen_nsIAsyncInputStream_h__
  6. #define __gen_nsIAsyncInputStream_h__
  7.  
  8.  
  9. #ifndef __gen_nsIInputStream_h__
  10. #include "nsIInputStream.h"
  11. #endif
  12.  
  13. /* For IDL files that don't want to include root IDL files. */
  14. #ifndef NS_NO_VTABLE
  15. #define NS_NO_VTABLE
  16. #endif
  17. class nsIInputStreamCallback; /* forward declaration */
  18.  
  19. class nsIEventTarget; /* forward declaration */
  20.  
  21.  
  22. /* starting interface:    nsIAsyncInputStream */
  23. #define NS_IASYNCINPUTSTREAM_IID_STR "15a15329-00de-44e8-ab06-0d0b0d43dc5b"
  24.  
  25. #define NS_IASYNCINPUTSTREAM_IID \
  26.   {0x15a15329, 0x00de, 0x44e8, \
  27.     { 0xab, 0x06, 0x0d, 0x0b, 0x0d, 0x43, 0xdc, 0x5b }}
  28.  
  29. /**
  30.  * If an input stream is non-blocking, it may return NS_BASE_STREAM_WOULD_BLOCK
  31.  * when read.  The caller must then wait for the stream to have some data to 
  32.  * read.  If the stream implements nsIAsyncInputStream, then the caller can use 
  33.  * this interface to request an asynchronous notification when the stream
  34.  * becomes readable or closed (via the AsyncWait method).
  35.  *
  36.  * While this interface is almost exclusively used with non-blocking streams, it
  37.  * is not necessary that nsIInputStream::isNonBlocking return true.  Nor is it
  38.  * necessary that a non-blocking nsIInputStream implementation also implement
  39.  * nsIAsyncInputStream.
  40.  */
  41. class NS_NO_VTABLE nsIAsyncInputStream : public nsIInputStream {
  42.  public: 
  43.  
  44.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IASYNCINPUTSTREAM_IID)
  45.  
  46.   /**
  47.      * This method closes the stream and sets its internal status.  If the 
  48.      * stream is already closed, then this method is ignored.  Once the stream
  49.      * is closed, the stream's status cannot be changed.  Any successful status
  50.      * code passed to this method is treated as NS_BASE_STREAM_CLOSED, which
  51.      * has an effect equivalent to nsIInputStream::close. 
  52.      *
  53.      * NOTE: this method exists in part to support pipes, which have both an 
  54.      * input end and an output end.  If the input end of a pipe is closed, then
  55.      * writes to the output end of the pipe will fail.  The error code returned 
  56.      * when an attempt is made to write to a "broken" pipe corresponds to the
  57.      * status code passed in when the input end of the pipe was closed, which
  58.      * greatly simplifies working with pipes in some cases.
  59.      *
  60.      * @param aStatus
  61.      *        The error that will be reported if this stream is accessed after
  62.      *        it has been closed.
  63.      */
  64.   /* void closeWithStatus (in nsresult aStatus); */
  65.   NS_IMETHOD CloseWithStatus(nsresult aStatus) = 0;
  66.  
  67.   /**
  68.      * Asynchronously wait for the stream to be readable or closed.  The
  69.      * notification is one-shot, meaning that each asyncWait call will result
  70.      * in exactly one notification callback.  After the OnInputStreamReady event
  71.      * is dispatched, the stream releases its reference to the 
  72.      * nsIInputStreamCallback object.  It is safe to call asyncWait again from the
  73.      * notification handler.
  74.      *
  75.      * This method may be called at any time (even if read has not been called).
  76.      * In other words, this method may be called when the stream already has
  77.      * data to read.  It may also be called when the stream is closed.  If the
  78.      * stream is already readable or closed when AsyncWait is called, then the
  79.      * OnInputStreamReady event will be dispatched immediately.  Otherwise, the
  80.      * event will be dispatched when the stream becomes readable or closed.
  81.      * 
  82.      * @param aCallback
  83.      *        This object is notified when the stream becomes ready.
  84.      * @param aFlags
  85.      *        This parameter specifies optional flags passed in to configure
  86.      *        the behavior of this method.  Pass zero to specify no flags.
  87.      * @param aRequestedCount
  88.      *        Wait until at least this many bytes can be read.  This is only
  89.      *        a suggestion to the underlying stream; it may be ignored.  The
  90.      *        caller may pass zero to indicate no preference.
  91.      * @param aEventTarget
  92.      *        Specify NULL to receive notification on ANY thread (possibly even
  93.      *        recursively on the calling thread -- i.e., synchronously), or
  94.      *        specify that the notification be delivered to a specific event
  95.      *        target.
  96.      */
  97.   /* void asyncWait (in nsIInputStreamCallback aCallback, in unsigned long aFlags, in unsigned long aRequestedCount, in nsIEventTarget aEventTarget); */
  98.   NS_IMETHOD AsyncWait(nsIInputStreamCallback *aCallback, PRUint32 aFlags, PRUint32 aRequestedCount, nsIEventTarget *aEventTarget) = 0;
  99.  
  100.   /**
  101.      * If passed to asyncWait, this flag overrides the default behavior,
  102.      * causing the OnInputStreamReady notification to be suppressed until the
  103.      * stream becomes closed (either as a result of closeWithStatus/close being
  104.      * called on the stream or possibly due to some error in the underlying
  105.      * stream).
  106.      */
  107.   enum { WAIT_CLOSURE_ONLY = 1U };
  108.  
  109. };
  110.  
  111. /* Use this macro when declaring classes that implement this interface. */
  112. #define NS_DECL_NSIASYNCINPUTSTREAM \
  113.   NS_IMETHOD CloseWithStatus(nsresult aStatus); \
  114.   NS_IMETHOD AsyncWait(nsIInputStreamCallback *aCallback, PRUint32 aFlags, PRUint32 aRequestedCount, nsIEventTarget *aEventTarget); \
  115.  
  116. /* Use this macro to declare functions that forward the behavior of this interface to another object. */
  117. #define NS_FORWARD_NSIASYNCINPUTSTREAM(_to) \
  118.   NS_IMETHOD CloseWithStatus(nsresult aStatus) { return _to CloseWithStatus(aStatus); } \
  119.   NS_IMETHOD AsyncWait(nsIInputStreamCallback *aCallback, PRUint32 aFlags, PRUint32 aRequestedCount, nsIEventTarget *aEventTarget) { return _to AsyncWait(aCallback, aFlags, aRequestedCount, aEventTarget); } \
  120.  
  121. /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
  122. #define NS_FORWARD_SAFE_NSIASYNCINPUTSTREAM(_to) \
  123.   NS_IMETHOD CloseWithStatus(nsresult aStatus) { return !_to ? NS_ERROR_NULL_POINTER : _to->CloseWithStatus(aStatus); } \
  124.   NS_IMETHOD AsyncWait(nsIInputStreamCallback *aCallback, PRUint32 aFlags, PRUint32 aRequestedCount, nsIEventTarget *aEventTarget) { return !_to ? NS_ERROR_NULL_POINTER : _to->AsyncWait(aCallback, aFlags, aRequestedCount, aEventTarget); } \
  125.  
  126. #if 0
  127. /* Use the code below as a template for the implementation class for this interface. */
  128.  
  129. /* Header file */
  130. class nsAsyncInputStream : public nsIAsyncInputStream
  131. {
  132. public:
  133.   NS_DECL_ISUPPORTS
  134.   NS_DECL_NSIASYNCINPUTSTREAM
  135.  
  136.   nsAsyncInputStream();
  137.  
  138. private:
  139.   ~nsAsyncInputStream();
  140.  
  141. protected:
  142.   /* additional members */
  143. };
  144.  
  145. /* Implementation file */
  146. NS_IMPL_ISUPPORTS1(nsAsyncInputStream, nsIAsyncInputStream)
  147.  
  148. nsAsyncInputStream::nsAsyncInputStream()
  149. {
  150.   /* member initializers and constructor code */
  151. }
  152.  
  153. nsAsyncInputStream::~nsAsyncInputStream()
  154. {
  155.   /* destructor code */
  156. }
  157.  
  158. /* void closeWithStatus (in nsresult aStatus); */
  159. NS_IMETHODIMP nsAsyncInputStream::CloseWithStatus(nsresult aStatus)
  160. {
  161.     return NS_ERROR_NOT_IMPLEMENTED;
  162. }
  163.  
  164. /* void asyncWait (in nsIInputStreamCallback aCallback, in unsigned long aFlags, in unsigned long aRequestedCount, in nsIEventTarget aEventTarget); */
  165. NS_IMETHODIMP nsAsyncInputStream::AsyncWait(nsIInputStreamCallback *aCallback, PRUint32 aFlags, PRUint32 aRequestedCount, nsIEventTarget *aEventTarget)
  166. {
  167.     return NS_ERROR_NOT_IMPLEMENTED;
  168. }
  169.  
  170. /* End of implementation class template. */
  171. #endif
  172.  
  173.  
  174. /* starting interface:    nsIInputStreamCallback */
  175. #define NS_IINPUTSTREAMCALLBACK_IID_STR "d1f28e94-3a6e-4050-a5f5-2e81b1fc2a43"
  176.  
  177. #define NS_IINPUTSTREAMCALLBACK_IID \
  178.   {0xd1f28e94, 0x3a6e, 0x4050, \
  179.     { 0xa5, 0xf5, 0x2e, 0x81, 0xb1, 0xfc, 0x2a, 0x43 }}
  180.  
  181. class NS_NO_VTABLE nsIInputStreamCallback : public nsISupports {
  182.  public: 
  183.  
  184.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IINPUTSTREAMCALLBACK_IID)
  185.  
  186.   /**
  187.  * This is a companion interface for nsIAsyncInputStream::asyncWait.
  188.  */
  189. /**
  190.      * Called to indicate that the stream is either readable or closed.
  191.      *
  192.      * @param aStream
  193.      *        The stream whose asyncWait method was called.
  194.      */
  195.   /* void onInputStreamReady (in nsIAsyncInputStream aStream); */
  196.   NS_IMETHOD OnInputStreamReady(nsIAsyncInputStream *aStream) = 0;
  197.  
  198. };
  199.  
  200. /* Use this macro when declaring classes that implement this interface. */
  201. #define NS_DECL_NSIINPUTSTREAMCALLBACK \
  202.   NS_IMETHOD OnInputStreamReady(nsIAsyncInputStream *aStream); 
  203.  
  204. /* Use this macro to declare functions that forward the behavior of this interface to another object. */
  205. #define NS_FORWARD_NSIINPUTSTREAMCALLBACK(_to) \
  206.   NS_IMETHOD OnInputStreamReady(nsIAsyncInputStream *aStream) { return _to OnInputStreamReady(aStream); } 
  207.  
  208. /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
  209. #define NS_FORWARD_SAFE_NSIINPUTSTREAMCALLBACK(_to) \
  210.   NS_IMETHOD OnInputStreamReady(nsIAsyncInputStream *aStream) { return !_to ? NS_ERROR_NULL_POINTER : _to->OnInputStreamReady(aStream); } 
  211.  
  212. #if 0
  213. /* Use the code below as a template for the implementation class for this interface. */
  214.  
  215. /* Header file */
  216. class nsInputStreamCallback : public nsIInputStreamCallback
  217. {
  218. public:
  219.   NS_DECL_ISUPPORTS
  220.   NS_DECL_NSIINPUTSTREAMCALLBACK
  221.  
  222.   nsInputStreamCallback();
  223.  
  224. private:
  225.   ~nsInputStreamCallback();
  226.  
  227. protected:
  228.   /* additional members */
  229. };
  230.  
  231. /* Implementation file */
  232. NS_IMPL_ISUPPORTS1(nsInputStreamCallback, nsIInputStreamCallback)
  233.  
  234. nsInputStreamCallback::nsInputStreamCallback()
  235. {
  236.   /* member initializers and constructor code */
  237. }
  238.  
  239. nsInputStreamCallback::~nsInputStreamCallback()
  240. {
  241.   /* destructor code */
  242. }
  243.  
  244. /* void onInputStreamReady (in nsIAsyncInputStream aStream); */
  245. NS_IMETHODIMP nsInputStreamCallback::OnInputStreamReady(nsIAsyncInputStream *aStream)
  246. {
  247.     return NS_ERROR_NOT_IMPLEMENTED;
  248. }
  249.  
  250. /* End of implementation class template. */
  251. #endif
  252.  
  253.  
  254. #endif /* __gen_nsIAsyncInputStream_h__ */
  255.